﻿package Ling;

public class Demo05 {
/*	定义一个方法，用来实现如下功能：
	​已知一个数组 arr = {19, 28, 37, 46, 50}; 用程序实现把数组中的元素值交换，
	​交换后的数组 arr = {50, 46, 37, 28, 19}; 并在控制台输出交换后的数组元素*/
	public static void main(String[] args) {
		int[] arr01 = {19, 28, 37, 46, 50};
		exchangeArr(arr01);
			
	}
	
	public static void exchangeArr(int[] arr01 ) {
		int[] arr02= new int[5];
		
		arr02[0]=arr01[4];
		arr02[1]=arr01[3];
		arr02[2]=arr01[2];
		arr02[3]=arr01[1];
		arr02[4]=arr01[0];
		
		for (int i = 0; i < arr02.length; i++) {
		if (i<arr02.length-1) {
				System.out.print(arr02[i]+",");
			}else {
				System.out.print(arr02[i]);
		}
		}
		
		
	}
}
